<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="f" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path=request.getContextPath();
%>    

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<link href="/resources/css/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="/resources/js/jquery-3.2.1/jquery.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/jquery.validate.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/localization/messages_zh.js"></script>
	<script type="text/javascript" src="/resources/css/bootstrap-4.3.1/js/bootstrap.js"></script>
</head>
<body>
	<!-- //Plan p = new Plan(id, proname, money, promanager, departid, details) -->
	<form action="addPlan" method="post" class = "addPlanForm">
	  <div class="form-group">
	    <label for="exampleFormControlInput1">项目名称</label>
	    <input type="text" class="form-control"  name = "proname">
	  </div>
	  
	  <div class="form-group">
	    <label for="exampleFormControlSelect1">所属部门</label>
	    <select class="form-control" id = "company" name = "departid">
	      
	    </select>
	  </div>
	  
	  <div class="form-group">
	    <label for="exampleFormControlInput1">投资金额</label>
	    <input type="text" class="form-control"  name = "money">
	  </div>
	  <div class="form-group">
	    <label for="exampleFormControlInput1">分管领导</label>
	    <input type="text" class="form-control"  name = "promanager">
	  </div>
	  
	  <div class="form-group">
	    <label for="exampleFormControlTextarea1">项目介绍</label>
	    <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" name = "details">
	    </textarea>
	  </div>
	  

	   
	    <input type = "button" value = "发布项目" onclick = "add()">
	</form>

	<script type="text/javascript">
	
	
		$.post("findComList",function(msg){
			
			console.log(msg);
			for(var i in msg){
				
				$("#company").append("<option value = "+msg[i].departId+">"+msg[i].department+"</option>")
				
			}	
		},"json")
	
		
		function add(){
			
			$.post("addPlan",$(".addPlanForm").serialize(),function(msg){
				
				if(msg > 0){
					alert("添加成功！");
					location = "findPlan"
				}else{
					
					alert("添加失败！");
				}
			},"json");
			
			
		}
	
	
	</script>

</body>
</html>